/* 
	
*/
var hair_Colo_new;
var status = -1;
var beauty = -1;
var hairCard = 5150040;
var types = -1;
var ct = -1;

function action(mode, type, selection) {
    if (mode == 0) {
		if (status != 1) {
			if (beauty == 0 || beauty == 2 || beauty == 4) {
				cm.sendOk("你还没做好心理准备吗？决定好了之后，请你再来和我说话。");
			} else if (beauty == 1 || beauty == 3) {
				cm.sendOk("怎么样？喜欢新换的发型么?哇～真是既高雅又美丽。哈哈哈，我的手艺还能差到那里去～需要更换发型的话，可以随时来找我，呵呵。");
			}
		}
        cm.dispose();
        return;
    } else {
        status++;
    }
    if (status == 0) {
        cm.sendSimple("你好。我是大头国的#b#p1012117##k。如果你有#b#t05150040##k，我可以为你设计一个发型。怎么样？\r\n#b#L0#更换第一组发型(使用皇家理发券)#l \r\n#b#L1#更换第二组发型(使用皇家理发券)#l");
    } else if (status == 1) {
		var hair = cm.getPlayerStat("HAIR");
		hair_Colo_new = [];
        if (selection == 0) {
            beauty = 0;
            if (cm.getPlayerStat("GENDER") == 0) {
                hair_Colo_new = [30000, 30010, 30020, 30030, 30040, 30050, 30060, 30070, 30080, 30090, 30100, 30110, 30120, 30130, 30140, 30150, 30160, 30170, 30180, 30190, 30200, 30210, 30220, 30230, 30240, 30250, 30260, 30270, 30280, 30290, 30300, 30310, 30320, 30330, 30340, 30350, 30360, 30370, 30380, 30400, 30410, 30420, 30430, 30440, 30450, 30460, 30470, 30480, 30490, 30510, 30520, 30530, 30540, 30550, 30560, 30570, 30590, 30600, 30610, 30620, 30630, 30640, 30650, 30660, 30670, 30680, 30700, 30710, 30720, 30730, 30740, 30750, 30760, 30770, 30780, 30790, 30800, 30810, 30820, 30830, 30840, 30850, 30860, 30870, 30880, 30890, 30900, 30910, 30920, 30930, 30940, 30950, 30990, 32160, 32440, 32470, 32490, 32500, 33000, 33040, 33050, 33060, 33070, 33080, 33090, 33100, 33110, 33120, 33130, 33140, 33150, 33170, 33180, 33190, 33200, 33210, 33220, 33230, 33240, 33250, 33260, 33270, 33280, 33290, 33300, 33310, 33320];
            } else {
                hair_Colo_new = [31000, 31010, 31020, 31030, 31040, 31050, 31060, 31070, 31080, 31090, 31100, 31110, 31120, 31130, 31140, 31150, 31160, 31170, 31180, 31190, 31200, 31210, 31220, 31230, 31240, 31250, 31260, 31270, 31280, 31290, 31300, 31310, 31320, 31330, 31340, 31350, 31360, 31370, 31380, 31400, 31410, 31420, 31430, 31440, 31450, 31460, 31470, 31480, 31490, 31510, 31520, 31530, 31540, 31550, 31560, 31590, 31610, 31620, 31630, 31640, 31650, 31660, 31670, 31680, 31690, 31700, 31710, 31720, 31730, 31740, 31750, 31760, 31770, 31780, 31790, 31800, 31810, 31820, 31830, 31840, 31850, 31860, 31870, 31880, 31890, 31900, 31910, 31920, 31930, 31940, 31950, 31990, 32120, 32130, 32140, 32150, 33030, 33160, 33590, 34000, 34010, 34040, 34050, 34060, 34070, 34080, 34090, 34100, 34110, 34120, 34130, 34140, 34150, 34160, 34170, 34180, 34190, 34200, 34210, 34220, 34230, 34240, 34250, 34260, 34270, 34280, 34290];
            }
        } else if (selection == 1) {
            beauty = 1;
            if (cm.getPlayerStat("GENDER") == 0) {
                hair_Colo_new = [33330, 33340, 33350, 33360, 33370, 33380, 33390, 33400, 33410, 33430, 33440, 33450, 33460, 33470, 33480, 33500, 33510, 33520, 33530, 33540, 33550, 33580, 33600, 33610, 33620, 33630, 33640, 33650, 33660, 33670, 33680, 33690, 33700, 33710, 33720, 33730, 33740, 33750, 33760, 33770, 33780, 33790, 33800, 33810, 33820, 33830, 33930, 33940, 33950, 33960, 33970, 33980, 33990, 34740, 36000, 36010, 36020, 36030, 36040, 36050, 36070, 36080, 36090, 36100, 36110, 36120, 36130, 36140, 36150, 36160, 36170, 36180, 36190, 36210, 36220, 36230, 36240, 36250, 36260, 36290, 36300, 36310, 36330, 36340, 36350, 36360, 36370, 36380, 36390, 36400, 36410, 36420, 36430, 36440, 36450, 36460, 36470, 36480, 36490, 36510, 36520, 36530, 36540, 36550, 36560, 36570, 36580, 36590, 36620, 36630, 36640, 36650, 36670, 36680, 36690, 36700, 36710, 36720, 36730, 36740, 36750, 36760, 36770, 36780, 36790, 36800, 36810, 36820, 36830, 36840, 36850, 36860, 36880, 36890, 36900, 36920, 36930, 36940, 36950, 36980, 36990];
            } else {
                hair_Colo_new = [34300, 34310, 34320, 34330, 34340, 34350, 34360, 34370, 34380, 34400, 34410, 34420, 34430, 34440, 34450, 34470, 34480, 34490, 34510, 34540, 34560, 34590, 34600, 34610, 34620, 34630, 34640, 34650, 34660, 34670, 34680, 34690, 34700, 34710, 34720, 34730, 34750, 34760, 34770, 34780, 34790, 34800, 34810, 34820, 34830, 34840, 34850, 34860, 34870, 34880, 34890, 34900, 34910, 34940, 34950, 34960, 34970, 34980, 34990, 37000, 37010, 37020, 37030, 37040, 37050, 37060, 37070, 37090, 37100, 37110, 37120, 37130, 37140];
            }
        }
		var iNow = 0;
		var hairTypeNow = [];
		for (var i = 0; i < hair_Colo_new.length; i++) {
			if (hair_Colo_new[i] != hair-hair%10) {
				hairTypeNow[iNow++] = hair_Colo_new[i] + (hair % 10);
			}
		}
		hair_Colo_new = cm.getCanHair(hairTypeNow);
		cm.sendSimple("那么你想...\r\n#b#L0#看看这个皇家有什么发型#l\r\n#b#L1#更换发型#l");
    } else if (status == 2) {
        if (selection == 0) {
			types = 0;
			if (hair_Colo_new.length == 0)
				cm.sendOk("出现未知错误。");
			else
				cm.askAvatar("随便看", hair_Colo_new, hairCard);
        } else if (selection == 1) {
			types = 1;
			if (beauty == 0 || beauty == 1) {
				cm.sendYesNo("使用皇家理发券，可以随机更换发型。你真的要使用#b#t0" + hairCard + "##k，更换发型吗？");
			} else {
				cm.sendOk("出现未知错误");
				cm.dispose();
			}
		}
    } else if (status == 3) {
        if (types == 0) {
			status = 0;
			action(mode, type, beauty);
		} else {
			if (cm.setRandomAvatar(hairCard, hair_Colo_new) == 1) {
				cm.sendOk("好了,让朋友们赞叹你的新发型吧!");
				cm.safeDispose();
			} else {
				cm.sendYesNo("您没有可使用的会员卡。是否想消耗980抵用券直接使用？");
			}
		}
    } else if (status == 4) {
		status = 2;
		if (cm.getChar().getCSPoints(1) >= 980)
			ct = 1;
		if (cm.getChar().getCSPoints(2) >= 980)
			ct = 2;
		if (ct != -1) {
			ct = -1;
			cm.gainNX(ct, -980);
			cm.gainItem(hairCard, 1);
		} else {
			beauty = -1;
		}
		action(mode, type, selection);
    }
}